#include "Header.h"
#include "HeavenGate.h"
#include "Clean.h"
#include "Test.h"

int main(int argc, char* argv[])
{
    char strBuff[20] = { 0 };
    const char* lpString = "Hello";

    Memcpy64((LongPtr64)strBuff, (LongPtr64)lpString, strlen(lpString));
    printf("%s\r\n", strBuff);

    printf("Teb: 0x%llX\r\n", GetTeb64());
    printf("Peb: 0x%llX\r\n", ((PTEB64)GetTeb64())->ProcessEnvironmentBlock);
    printf("Peb: 0x%llX\r\n", GetPeb64());

    printf("Ntdll Base: %llX\r\n", __GetModuleHandle64(L"ntdll.dll"));
    printf("Ntdll Base: %llX\r\n", GetNtdll64());
    printf("Wow64 Base: %llX\r\n", __GetModuleHandle64(L"wow64.dll"));
    printf("Wow64 Base: %llX\r\n", GetModuleHandle64(L"wow64.dll"));

    printf("LdrGetProcedureAddress: %llX\r\n", getLdrGetProcedureAddress());
    printf("LdrGetProcedureAddress: %llX\r\n", GetLdrGetProcedureAddress());

    printf("NtQueryVirtualMemory: %llX\r\n", __GetProcAddress64(getNTDLL64(), "NtQueryVirtualMemory"));
    printf("NtQueryVirtualMemory: %llX\r\n", GetProcAddress64(GetNtdll64(), "NtQueryVirtualMemory"));

    printf("NtCreateProcess: %llX\r\n", __GetProcAddress64(getNTDLL64(), "NtCreateProcess"));
    printf("NtCreateProcess: %llX\r\n", GetProcAddress64(GetNtdll64(), "NtCreateProcess"));

    printf("NtAllocateVirtualMemory: %llX\r\n", __GetProcAddress64(getNTDLL64(), "NtAllocateVirtualMemory"));
    printf("NtWriteVirtualMemory: %llX\r\n", __GetProcAddress64(getNTDLL64(), "NtWriteVirtualMemory"));
    printf("NtAllocateVirtualMemory: %llX\r\n", GetProcAddress64(GetNtdll64(), "NtAllocateVirtualMemory"));
    printf("NtAllocateVirtualMemory: %llX\r\n", GetProcAddress64(GetNtdll64(), "NtAllocateVirtualMemory"));
    printf("NtWriteVirtualMemory: %llX\r\n", GetProcAddress64(GetNtdll64(), "NtWriteVirtualMemory"));
    printf("NtWriteVirtualMemory: %llX\r\n", GetProcAddress64(GetNtdll64(), "NtWriteVirtualMemory"));

    HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, 7892);
    DWORD64 lpVa = VirtualAllocEx64(hProcess, 0x70000000000, 0x1000, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);

    SIZE_T stLen;
    BOOL bRet = WriteProcessMemory64(hProcess, lpVa, (LPVOID)lpString, strlen(lpString), &stLen);

    char Buff[20] = { 0 };
    bRet = ReadProcessMemory64(hProcess, lpVa, (LPVOID)Buff, 20, &stLen);

    printf("%s\r\n", Buff);

    VirtualFreeEx64(hProcess, lpVa, 0, MEM_RELEASE);

    CleanVmFunctions();

    return 0;
}
